<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试</title>
</head>
<body>

<div id="app">
    <!--<h2>当前计数：{{count}}</h2>-->
    <!--<button v-on:click="count++">+</button>-->
    <!--<button v-on:click="count--">-</button>-->

    <h2>当前计数：{{count}}</h2>
    <button v-on:click="add">+</button>
    <button v-on:click="sub">-</button>
</div>

<script src="../js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            count: 0
        },
        methods: {
            add: function() {
                console.log("add方法被执行");
                this.count++;
            },
            sub: function() {
                console.log("sub方法被执行");
                this.count--;
            }
        }
    });
</script>
</body>
</html>